<?php
$cmd = trim($_POST['cmd']);
$pass = trim($_POST['pass']);

if($cmd == 'encode')
{
	$result = base64_encode($pass);
}
elseif($cmd == 'decode')
{
	$result = base64_decode($pass);	
}
?>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
		<title>密码生成/解码器</title>
	</head>
	<body>
		<form method="post">
		<input type="hidden" name="cmd" value="encode">
		<input type="text" name="pass" value="<?=$cmd=='encode'?$pass:''?>" style="width:300px;">
		<input type="submit" value="生成密码" style="cursor:pointer">
		<?=$cmd=='encode'?$result:''?>
		</form>
		<br/>
		<br/>
		<form method="post">
		<input type="hidden" name="cmd" value="decode">
		<input type="text" name="pass" value="<?=$cmd=='decode'?$pass:''?>" style="width:300px;">
		<input type="submit" value="还原密码" style="cursor:pointer">
		<?=$cmd=='decode'?$result:''?>
		</form>
	</body>
</html>